package com.djx.comm.entity;

import com.djx.comm.util.AesUtils;
import lombok.*;
import lombok.experimental.Accessors;

/**
 * @author dingjunxiong
 */
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class User extends BaseEntity{
    private String name;
    private String phone;
    private Integer sex;
    private String account;
    private String password;


    /**
     * 数据加密
     */
    public void aesEncryptVo() throws Exception {
        this.name = AesUtils.aesEncrypt(this.name);
        this.phone = AesUtils.aesEncrypt(this.phone);
        this.account = AesUtils.aesEncrypt(this.account);
        this.password = AesUtils.aesEncrypt(this.password);
    }

    /**
     * 数据解密
     */
    public void aesDecryptVo() throws Exception {
        this.name = AesUtils.aesDecrypt(this.name);
        this.phone = AesUtils.aesDecrypt(this.phone);
        this.account = AesUtils.aesDecrypt(this.account);
        this.password = AesUtils.aesDecrypt(this.password);
    }
}
